Skip to content

fix(tabs): preserve active header during restore#2141

Merged
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
bajrangCoder:fix/restored-active-tab-header
May 31, 2026
Merged

fix(tabs): preserve active header during restore#2141
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
bajrangCoder:fix/restored-active-tab-header

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

This was the issue : 👇
Screenshot_20260531-111613 Acode

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 31, 2026

Greptile Summary

This PR fixes a bug where restoring multiple tabs caused the active file header to be overwritten with the name of subsequently-added (non-active) files. The one-line guard ensures $header.text is only set in addFile when no active file has been established yet.

  • Root cause fixed: In restoreFiles.js, multiple EditorFile constructors run synchronously; if the first file had render: true it became active (setting the header via switchFile), but every subsequent addFile call unconditionally overwrote $header.text with the non-active file's name.
  • Fix scope: A single if (!manager.activeFile) guard in addFile; all other header-update paths (switchFile, the filename setter) are unaffected and continue to work correctly.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted guard that only prevents a silent header overwrite during session restore without touching any other code path.

The fix is a single conditional wrapping one assignment in addFile. All downstream header-update paths (switchFile, the filename setter) remain untouched. Edge cases — fresh start with no active file, background-open with render: false, and plugin-triggered opens — are all handled correctly by existing code that runs after addFile. No regressions are introduced.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/editorManager.js Added an if (!manager.activeFile) guard around $header.text = file.name in addFile to prevent non-active files from overwriting the header during session restore.

Sequence Diagram

sequenceDiagram
    participant RF as restoreFiles.js
    participant EF as EditorFile(constructor)
    participant AM as addFile()
    participant MK as makeActive/switchFile()

    RF->>EF: "new EditorFile(file0, {render:true})"
    EF->>AM: addFile(file0) — activeFile is null
    AM-->>AM: "$header.text = file0.name"
    EF->>MK: render() → makeActive()
    MK-->>MK: "manager.activeFile = file0, $header.text = file0.filename"

    RF->>EF: "new EditorFile(file1, {render:false})"
    EF->>AM: "addFile(file1) — activeFile = file0"
    Note over AM: OLD: $header.text = file1.name (bug)<br/>NEW: guard skips update

    RF->>EF: "new EditorFile(file2, {render:false})"
    EF->>AM: "addFile(file2) — activeFile = file0"
    Note over AM: NEW: guard skips update, header stays = file0.filename
Loading

Reviews (1): Last reviewed commit: "fix(tabs): preserve active header during..." | Re-trigger Greptile

@bajrangCoder bajrangCoder merged commit c047504 into Acode-Foundation:main May 31, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix/restored-active-tab-header branch May 31, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant